home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / c / tox.lha / tox / tox.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-23  |  3.9 KB  |  158 lines

  1. /*-------------------------------------------------------------------------
  2.  * tox - an XML tokenizer
  3.  *
  4.  * Copyright (c) 2000 Eckhart Köppen
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Library General Public
  8.  * License as published by the Free Software Foundation; either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the GNU
  14.  * Library General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Library General Public
  17.  * License along with this library; if not, write to the
  18.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.  * Boston, MA 02111-1307, USA.
  20.  *-----------------------------------------------------------------------*/
  21.  
  22. /* $Id: tox.h,v 1.10 2000/05/19 14:28:37 koeppen Exp $ */
  23.  
  24. #ifndef __TOX_H
  25. #define __TOX_H
  26.  
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30.  
  31. typedef unsigned short char_t;
  32.  
  33. /* typedef unsigned char char_t; */
  34.  
  35. typedef struct
  36. {
  37.     unsigned int accept_type;
  38.     char_t accept_value;
  39.     int next_state;
  40.     unsigned char action;
  41. } state_def;
  42.  
  43. typedef struct
  44. {
  45.     char_t start;
  46.     char_t end;
  47. } char_range;
  48.  
  49. struct _parser_state;
  50.  
  51. typedef void (callback)(struct _parser_state *);
  52.  
  53. typedef struct _parser_state
  54. {
  55.     char_t *text;
  56.     int current;
  57.     int maxtext;
  58.  
  59.     int state;
  60.  
  61.     char pump;
  62.     char_t *buffer;
  63.     int bcurrent;
  64.     int maxbuf;
  65.  
  66.     int squoteLevel;
  67.     int dquoteLevel;
  68.     int angleBracketLevel;
  69.  
  70.     callback *element_callback;
  71.     callback *attrname_callback;
  72.     callback *attrval_callback;
  73.     callback *word_callback;
  74.     callback *ws_callback;
  75.     
  76.     void *userdata;
  77. } parser_state;
  78.  
  79. typedef struct
  80. {
  81.     parser_state *state;
  82.     
  83.     callback *element_callback;
  84.     callback *attrname_callback;
  85.     callback *attrval_callback;
  86.     callback *word_callback;
  87. } parser;
  88.  
  89. #define STATE_ERROR             -2
  90. #define STATE_END               -1
  91. #define STATE_CONTENT            0
  92. #define STATE_STARTTAG_START     1
  93. #define STATE_REF_START          2
  94. #define STATE_CHARDATA           3
  95. #define STATE_ENDTAG_START       4
  96. #define STATE_STARTTAG_NAME      5
  97. #define STATE_REF_NAME           6
  98. #define STATE_ENDTAG_NAME        7
  99. #define STATE_STARTTAG_NAMEEND   8
  100. #define STATE_ENDTAG_NAMEEND     9
  101. #define STATE_ATTR_NAME         10
  102. #define STATE_ATTR_NAMEEND      11
  103. #define STATE_ATTR_VALSTART     12
  104. #define STATE_ATTR_VALDQUOT     13
  105. #define STATE_EMPTYTAG_END      14
  106. #define STATE_ATTR_VALDQUOT_REF 15
  107. #define STATE_ATTR_VDQ_REFNAME  16
  108. #define STATE_ATTR_VALSQUOT     17
  109. #define STATE_ATTR_VALSQUOT_REF 18
  110. #define STATE_ATTR_VSQ_REFNAME  19
  111. #define STATE_DTD_START         20
  112. #define STATE_MARKUPDECL_START  21
  113. #define STATE_CDATA             22
  114. #define STATE_CDATA_1ST_BRACKET 23
  115. #define STATE_CDATA_2ND_BRACKET 24
  116. #define STATE_PI                25
  117. #define STATE_PI_END_QMARK      26
  118. #define STATE_COMMENT           27
  119. #define STATE_COMMENT_1ST_DASH  28
  120. #define STATE_COMMENT_2ND_DASH  29
  121. #define STATE_REF_NUMBER        30
  122. #define    STATE_REF_HEX_NUMBER_1  31
  123. #define    STATE_REF_HEX_NUMBER    32
  124. #define STATE_REF_DEC_NUMBER    33
  125. #define STATE_WS_CONTENT        34
  126. #define STATE_WORD_CONTENT      35
  127. #define STATE_COMMENT_START_1ST 36
  128. #define STATE_DOCTYPE_D         37
  129. #define STATE_DOCTYPE_O         38
  130. #define STATE_DOCTYPE_C         39
  131. #define STATE_DOCTYPE_T         40
  132. #define STATE_DOCTYPE_Y         41
  133. #define STATE_DOCTYPE_P         42
  134. #define STATE_CDATA_BRACKET     43
  135. #define STATE_CDATA_C           44
  136. #define STATE_CDATA_D           45
  137. #define STATE_CDATA_A           46
  138. #define STATE_CDATA_T           47
  139. #define STATE_CDATA_A2          48
  140.  
  141. void tox_parse (parser_state *parser);
  142. int tox_wstrcmp (char_t *s1, char *s2);
  143. int tox_strlen (char *s);
  144.  
  145. #ifdef __cplusplus
  146. }
  147. #endif
  148.  
  149. #endif
  150.  
  151.  
  152. /*
  153.  * Local variables:
  154.  * c-basic-offset: 4
  155.  * tab-width: 4
  156.  * End:
  157.  */
  158.